﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using VAdvantage.Utility;
using VAdvantage.Classes;

namespace VAdvantage.Framework
{
    public partial class EmailFormat : ChildWindow
    {
        string strValue;
        /* Save latter or mail to opened window or save for all */
        bool forAll = false;

        public EmailFormat(string fileName)
           // : base(false, false, false, Msg.GetMsg(Envs.GetCtx(), "SaveNewRecord"))
        {
            InitializeComponent();
            LayoutRoot.Background = new SolidColorBrush(DataBase.GlobalVariable.WINDOW_BACK_COLOR);
            vTxtFileName.Text = fileName;
            if (!(vTxtFileName.Text.Trim().Length > 0))
            {
                vbtnOk.Visibility = Visibility.Collapsed;
                vchkAll.IsEnabled = false;
                this.DialogResult = true;
            }
            else
            {
                vchkAll.IsEnabled = true;
                vbtnOk.Visibility = Visibility.Visible;
                SetText = vTxtFileName.Text.Trim();
            }
        }

        public string GetText
        {
            get
            {
                return strValue;
            }

        }

        public string SetText
        {

            set
            {
                strValue = value;
            }
        }

        /// <summary>
        /// save 'this' format for all window or not
        /// </summary>
        /// Harwinder
        public bool SaveForAll
        {
            get
            {
                return forAll;
            }
            set
            {
                forAll = value;
            }
        }
       
        private void vbtnOk_Click(object sender, RoutedEventArgs e)
        {
            vbtnOk.IsEnabled = false;
            forAll = (bool)vchkAll.IsChecked;
            if (vTxtFileName.Text.Trim().Length > 0)
            {
                SetText = vTxtFileName.Text.Trim();

                //this.Dispose();
            }
            else
            {
                vbtnOk.IsEnabled = true;
                ShowMessage.Error("FileNameMendatory", true, "");
                return;
            }
            this.DialogResult = true;
           // this.DialogResult = vbtnOk.DialogResult;
       //     this.Close();
        }

        private void vbtnCancel_Click(object sender, RoutedEventArgs e)
        {
            
            this.DialogResult = false;
           // this.Close();
        }

        private void ChildWindow_Closed(object sender, EventArgs e)
        {

        }

        private void vTxtFileName_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (vTxtFileName.Text.Trim().Length > 0)
            {
                vbtnOk.Visibility = Visibility.Visible;
                vchkAll.IsEnabled = true;
            }
            else
            {
                vbtnOk.Visibility = Visibility.Collapsed;
                vchkAll.IsEnabled = false;
            }
        }
    }
}

